attribute vec4 aPosition;
uniform vec4 uColor;
uniform mat4 uMatrix;

// 绕任意轴旋转
mat4 rotate(vec3 axis,float angle){
    float x=axis.x,y=axis.y,z=axis.z;
    float radian=radians(angle);
    float s=sin(radian),c=cos(radian);
    float t=1.-c;
    float m0=x*x*t+c,
    m1=x*y*t-z*s,
    m2=x*z*t+y*s,
    m3=0.,
    m4=y*x*t+z*s,
    m5=y*y*t+c,
    m6=y*z*t-x*s,
    m7=0.,
    m8=z*x*t-y*s,
    m9=z*y*t+x*s,
    m10=z*z*t+c,
    m11=0.,
    m12=0.,
    m13=0.,
    m14=0.,
    m15=1.;
    // 按列填充
    return mat4(
        m0,m1,m2,m3,// 第一列
        m4,m5,m6,m7,// 第二列
        m8,m9,m10,m11,// 第三列
        m12,m13,m14,m15// 第四列
    );
}

// 先旋转,再平移,最后缩放
void main(){
    mat4 mr=rotate(vec3(1,1,0),10.);
    vec4 newPosition=mr*aPosition;
    gl_Position=newPosition;
}

